package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.UserPartyDevelop;
import com.ruoyi.system.service.IUserPartyDevelopService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 党员发展状态Controller
 * 
 * @author ruoyi
 * @date 2024-07-25
 */
@RestController
@RequestMapping("/system/develop")
public class UserPartyDevelopController extends BaseController
{
    @Autowired
    private IUserPartyDevelopService userPartyDevelopService;

    /**
     * 查询党员发展状态列表
     */
//    @PreAuthorize("@ss.hasPermi('system:develop:list')")
    @GetMapping("/list")
    public TableDataInfo list(UserPartyDevelop userPartyDevelop)
    {
        startPage();
        List<UserPartyDevelop> list = userPartyDevelopService.selectUserPartyDevelopList(userPartyDevelop);
        return getDataTable(list);
    }
    
    /**
     * 根据文件审核状态查询党员发展列表
     */
//    @PreAuthorize("@ss.hasPermi('system:develop:list')")
    @GetMapping("/checkStatusList")
    public TableDataInfo selectUserCheckStatus(UserPartyDevelop userPartyDevelop)
    {
        startPage();
        List<UserPartyDevelop> list = userPartyDevelopService.selectUserCheckStatus(userPartyDevelop);
        return getDataTable(list);
    }

    /**
     * 导出党员发展状态列表
     */
    @PreAuthorize("@ss.hasPermi('system:develop:export')")
    @Log(title = "党员发展状态", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, UserPartyDevelop userPartyDevelop)
    {
        List<UserPartyDevelop> list = userPartyDevelopService.selectUserPartyDevelopList(userPartyDevelop);
        ExcelUtil<UserPartyDevelop> util = new ExcelUtil<UserPartyDevelop>(UserPartyDevelop.class);
        util.exportExcel(response, list, "党员发展状态数据");
    }

    /**
     * 获取党员发展状态详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:develop:query')")
    @GetMapping(value = "/{userId}")
    public AjaxResult getInfo(@PathVariable("userId") Long userId)
    {
        return success(userPartyDevelopService.selectUserPartyDevelopByUserId(userId));
    }

    /**
     * 新增党员发展状态
     */
//    @PreAuthorize("@ss.hasPermi('system:develop:add')")
    @Log(title = "党员发展状态", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody UserPartyDevelop userPartyDevelop)
    {
        return toAjax(userPartyDevelopService.insertUserPartyDevelop(userPartyDevelop));
    }

    /**
     * 修改党员发展状态
     */
//    @PreAuthorize("@ss.hasPermi('system:develop:edit')")
    @Log(title = "党员发展状态", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody UserPartyDevelop userPartyDevelop)
    {
        return toAjax(userPartyDevelopService.updateUserPartyDevelop(userPartyDevelop));
    }

    /**
     * 删除党员发展状态
     */
//    @PreAuthorize("@ss.hasPermi('system:develop:remove')")
    @Log(title = "党员发展状态", businessType = BusinessType.DELETE)
	@DeleteMapping("/{userIds}")
    public AjaxResult remove(@PathVariable Long[] userIds)
    {
        return toAjax(userPartyDevelopService.deleteUserPartyDevelopByUserIds(userIds));
    }
}
